/*
可编辑插件
2012-11-27 by huanran.zhao
<span class="editable" data="{{'table='|cat:$table|cat:'&field=title&id='|cat:$val.id|encode}}"></span>
*/
$(document).ready(function(){
	var $editable_click_num = 0;
	$('.editable').live('dblclick',function(){
		_this = $(this);
		_this.addClass('label');//编辑状态样式
		var data = $(this).attr('data');
		var text = $(this).attr('oldvalue')?$(this).attr('oldvalue'):$(this).html();
		var title = $(this).attr('title')?$(this).attr('title'):'修改参数';
		myUi.prompt(title,function(content){
			if(content){
				if(content){
					$.ajax({
							type: "POST",
							url: myeditableurl,
							data: {params:data, value:content, oldvalue:text},//data -> table=config&field=ordering&id=1
							async: false,
							success:function(xml){if(xml!='')alert(xml);else document.location.reload();},
							error:function(msg){}//请求失败时
						});
				}
			}else{
				_this.removeClass('label');//编辑状态样式
			}
		},true);
		$('.ui_text').val(text);
	});
});